package com.hnyfkj.jyindustry.biz.wenjian.controller;

import com.hnyfkj.jyindustry.biz.wenjian.service.IUploadService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 文件上传
 *
 * @Author Bys
 */
@Controller
@RequestMapping("/commonFile")
public class UploadController {
    @Resource
    private IUploadService uploadService;

    /**
     * 多文件
     */
    @PostMapping("/uploadFiles")
    @ResponseBody
    public String uploadFiles(@RequestParam("file") MultipartFile[] file) throws Exception {
        return uploadService.uploadFiles(file);
    }

    /**
     * 单文件上传
     */
    @PostMapping("/uploadFile")
    @ResponseBody
    public String uploadFiles(@RequestParam("file")MultipartFile file) throws Exception {
        String s = uploadService.uploadFile(file);
        return s;
    }

    /**
     * 分片上传
     */
    @PostMapping("/shardUploadFile")
    @ResponseBody
    public String shardUploadFile(@RequestParam("file")MultipartFile file) throws Exception {
        String s = uploadService.shardUploadFile(file);
        return s;
    }
}
